//
//  StoreDetailsViewController.m
//  Manage
//
//  Created by 杨康 on 2017/11/15.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "StoreDetailsViewController.h"
#import "StoreNameViewController.h"
@interface StoreDetailsViewController ()
@property(nonatomic,strong)ykTableView *tableView;
@end

@implementation StoreDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"门店详情";
    UIButton *leftButton=(UIButton *)self.navigationItem.leftBarButtonItem.customView;
    leftButton.selected=YES;
    
    
    self.tableView=[SingLeton myTableViewWithFrame:CGRectMake(0, TOP_HEIGHT+10, SCREEN_WIDTH, SCREEN_HEIGHT-TOP_HEIGHT-10) withRefresh:NO didSelect:^(ykTableView *tableView, NSIndexPath *indexPath) {
        UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
        if ([cell.textLabel.text isEqualToString:@"门店名称"]) {
            StoreNameViewController *vc=[[StoreNameViewController alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }];
    [self.view addSubview:self.tableView];
    
    //系统cell
    [self.tableView.dataArray removeAllObjects];
    NSMutableArray *itemArr=[NSMutableArray array];
    
    
    
    cellData *dataObj=[[cellData alloc]init];
    dataObj.text=@"门店名称";
    dataObj.detailText=@"门店名称";
    
    cellData *dataObj2=[[cellData alloc]init];
    dataObj2.text=@"地址";
    dataObj2.detailText=@"我家在东北松花江上啊我家在东北松花江上啊";
    
    
    cellData *dataObj3=[[cellData alloc]init];
    dataObj3.text=@"联系人";
    dataObj3.detailText=@"某某某";
    
    
    cellData *dataObj4=[[cellData alloc]init];
    dataObj4.text=@"联系电话";
    dataObj4.detailText=@"13800000000";
    
    
    cellData *dataObj5=[[cellData alloc]init];
    dataObj5.text=@"联系电话";
    dataObj5.detailText=@"13800000000";
    
    cellData *dataObj6=[[cellData alloc]init];
    dataObj6.text=@"联系电话";
    dataObj6.detailText=@"13800000000";
    
    
    
    
    
    
    
    
    [itemArr addObject:dataObj];
    [itemArr addObject:dataObj2];
    [itemArr addObject:dataObj3];
    [itemArr addObject:dataObj4];
    [itemArr addObject:dataObj5];
    [itemArr addObject:dataObj6];
    
    
    
    
    [self.tableView.dataArray addObject:itemArr];
    [self.tableView reloadData];
    self.tableView.tableFooterView=[self customFootView];
}

-(UIView *)customFootView
{
    UIView *footView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    
    UIButton *saveBtn=[SingLeton endButton:[UIColor colorQ] andTitle:@"保存" RequestSuccess:^(UIButton *btn) {
        
    }];
    [footView addSubview:saveBtn];
    [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(20);
        make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH-60)/2, 44));
    }];
    
    UIButton *deleteBtn=[SingLeton endButton:[UIColor colorWithHexString:@"ff556d"] andTitle:@"删除" RequestSuccess:^(UIButton *btn) {
        UIAlertController *alertController=[UIAlertController alertControllerWithTitle:@"删除门店" message:@"确定要删除门店吗?" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *noAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        UIAlertAction *someAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        
        [alertController addAction:noAction];
        [alertController addAction:someAction];
        [self presentViewController:alertController animated:YES completion:nil];
        [noAction setValue:[UIColor color3] forKey:@"titleTextColor"];
    }];
    [footView addSubview:deleteBtn];
    [deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(saveBtn);
        make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH-60)/2, 44));
    }];
    return footView;
}
@end
